var app = require('http').createServer(handler)
  // , io = require('socket.io').listen(app)
  , io = require('socket.io')(app, { path:'/api/ws/dataset' })
  , fs = require('fs')
 
app.listen(10000);
 
function handler (req, res) {
  fs.readFile(__dirname + '/index.html',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }
 
    res.writeHead(200);
    res.end(data);
  });
}
 
io.sockets.on('connection', function (socket) {
  socket.emit('push', { hello1: 'world' });
  socket.on('push_ack', function (data) {
    console.log(data);
  });


  setInterval(function() {
    socket.emit('push', {time1: new Date().getTime()});
  }, 2000);

});

io.of('/chat').on('connection', function (socket) {
  socket.emit('push', { hello2: 'world' });
  socket.on('push_ack', function (data) {
    console.log(data);
  });


  setInterval(function() {
    socket.emit('push', {time2: new Date().getTime()});
  }, 2000);

});